/**
 * 记录订阅者
 */
const subscribes = []

export const subscribe = (fn) => {
  console.log('订阅消息', fn)
  subscribes.push(fn)
  console.log('订阅消息', subscribes)
}

export const publish = (data) => {
  console.log('发布消息', data)
  subscribes.forEach((fn) => fn && fn(data))
}
